<?php

class Application_Registry_Session extends Application_Registry {

    /**
     * @var Application_Registry_Session
     */
    private static $_instance = null;

    /**
     * @return Application_Registry_Session
     */
    public static function getInstance() {
        if(self::$_instance === null) {
            self::$_instance = new self;
        }
        return self::$_instance;
    }

    public function __construct() {
        session_start();
        if(!array_key_exists(__CLASS__, $_SESSION)) $_SESSION[__CLASS__] = array();
    }

    public function get($key) {
        if (isset($_SESSION[__CLASS__][$key])) {
            return $_SESSION[__CLASS__][$key];
        }
    }

    public function set($key, $val) {
        $_SESSION[__CLASS__][$key] = $val;
    }
    
    public function getValues() {
        return $_SESSION[__CLASS__];
    }

}

?>